from langchain.chains import ConversationChain
from langchain.memory import ConversationTokenBufferMemory
from tool import langchain_client
if __name__ == '__main__':
    # max_token_limit=30表明只保留最近的30个token
    memory = ConversationTokenBufferMemory(llm=langchain_client, max_token_limit=30)
    memory.save_context({"input": "朝辞白帝彩云间，"}, {"output": "千里江陵一日还。"})
    memory.save_context({"input": "两岸猿声啼不住，"}, {"output": "轻舟已过万重山。"})
    memory_info = memory.load_memory_variables({})
    print(memory_info)